package com.example.mykotilin.room

import android.content.Context

import com.example.mykotilin.room.persistence.UserDao
import com.example.mykotilin.room.persistence.UserDatabase

object Injection {
    //获取表对象
    fun providerUserDataSource(context: Context) : UserDao{
        val database = UserDatabase.getInstance(context);
        return database.userDao();
    }

    /**
     * 放在工厂里面
     */
    fun provideViewModelFactory(context: Context): ViewModelFactory {
        val dataSource = providerUserDataSource(context);//并将dao对象传送到viewmodel工厂。
        return ViewModelFactory(dataSource)
    }
}